package com.wanlian.router.ui.main.yun;

import android.support.annotation.Nullable;
import android.widget.TextView;

import com.smart.android.ui.BaseActivity;
import com.smart.android.ui.app.IntentExtra;
import com.smart.android.utils.DateTime;
import com.wanlian.router.R;
import com.wanlian.router.bean.YunFile;
import com.wanlian.router.net.NetWorkingClient;
import com.wanlian.router.net.ResponseData;
import com.wanlian.router.net.internal.INetCallBack;

import java.util.Locale;

import butterknife.BindView;

/**
 * Created by Hyu on 2018/10/10.
 * Email: fvaryu@163.com
 */
public class YunFileDetailActivity extends BaseActivity {

    @BindView(R.id.tv_path)
    TextView tv_path;
    @BindView(R.id.tv_name)
    TextView tv_name;
    @BindView(R.id.tv_size)
    TextView tv_size;
    @BindView(R.id.tv_time)
    TextView tv_time;

    @Override
    protected int layout() {
        return R.layout.activity_yun_file_detail;
    }

    @Override
    public void initUI() {
        super.initUI();
        setTitle("详细信息");
    }

    @Override
    public void initData() {
        super.initData();
        int id = getIntent().getIntExtra(IntentExtra.EXTRA_ID, 0);

        NetWorkingClient.getInstance().queryYunFileDetail(getActivity(), id, new INetCallBack<YunFile>() {
            @Override
            public void onFinish(ResponseData response, @Nullable YunFile yunFile) {
                if (response.isSuccess()) {
                    if (yunFile == null) {
                        return;
                    }
                    tv_name.setText(yunFile.getFileName());
                    tv_path.setText(yunFile.getFilePath());
                    tv_size.setText(String.format(Locale.getDefault(), "%s", yunFile.getUISize()));
                    tv_time.setText( DateTime.getDateByType(yunFile.getUploadTime(), "yyyy/MM/dd HH:mm"));
                }else {
                    showToast(response.getMessage());
                }
            }
        });
    }
}
